home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / Utilities ƒ / MPW Tools ƒ / Simula4.07 / Simula 4.07ƒ / SInterfaces / defaultAppleMenu.sim next >
Encoding:
Text File  |  1989-04-29  |  2.9 KB  |  85 lines  |  [TEXT/MPS ]

  1. % ---------------------------------------------------------------------------
  2. %    Class DefaultAppleMenu
  3. %
  4. % Part of the Lund Software interface to Macintosh Toolbox
  5. % DefaultAppleMenu is designed to act as the first alternative
  6. % in the MenuBar. It (hopefully) acts as a standard Apple menu.
  7. % An aplication using this class will not need to bother about
  8. % desk accesoirs.
  9. %
  10. % 890413/Boris Magnusson
  11. %
  12. % ---------------------------------------------------------------------------
  13. External class MacRect="::SInterfaces:macRect";
  14. External class MacEvent="::SInterfaces:macEvent";
  15. External class MacMenu="::SInterfaces:MacMenu";
  16. External class macMenuItem="::SInterfaces:MacMenuItem";
  17. External class toolboxMenu="::SInterfaces:toolboxMenu";
  18. External class toolboxEvent="::SInterfaces:toolboxEvent";
  19. External class MacDeskmgr="::Sinterfaces:Macdeskmgr";
  20. MacMenu class DefaultAppleMenu; 
  21. begin
  22.     ref(toolboxMenu) TRAP;
  23.     ref(macdeskmgr) desk;
  24.  
  25. ! This procedure is virtually bound and replaces the default one in MacMenu.
  26. ! It is called from MenuBar each time a menu item in the apple menu is selected.
  27. ;
  28.     procedure doMenu(menuid,item); integer menuid,item;
  29.     begin
  30.         ref(macMenuItem) userAlternative;
  31.         text theAcc;
  32.         if Item=1 then
  33.         begin
  34.             UserAlternative:- FindItem(Item);
  35.             if Useralternative=/=None then
  36.                 Useralternative.doMenu(menuid,Item)
  37.             else
  38.             begin
  39.             ! Window describing the application ;
  40.                 ref(macWindow) tempW;
  41.                 text T;
  42.                 ref(macRect) Wbounds;
  43.                 ref(macEvent) theEvent;
  44.                 ref(ToolboxEvent) TRAP;
  45.                 integer mousedownmask=2;
  46.                 wbounds:- new macRect; 
  47.                 inspect wbounds do 
  48.                     begin top:=50;left:=50;bottom:=50+85;right:=50+250; end;
  49.                 theEvent:-new macEvent;
  50.                 TRAP:-new TOOLBOXEvent;
  51.                 tempW:-new macWindow;
  52.                 tempW.newWindow(Wbounds," ",true,1,none,false,0);
  53.                 tempW.setport;
  54.                 tempW.MoveTo(10,10);T:-"This application was developed using";tempW.drawText(T,0,T.length);
  55.                 tempW.MoveTo(10,25);T:-"the Lund SIMULA system from";tempW.drawText(T,0,T.length);
  56.                 tempW.MoveTo(10,50);T:-"      Lund Software House AB";tempW.drawText(T,0,T.length);
  57.                 tempW.MoveTo(10,65);T:-"      Box 7056";tempW.drawText(T,0,T.length);
  58.                 tempW.MoveTo(10,80);T:-"      S-220 07 LUND, Sweden";tempW.drawText(T,0,T.length);
  59.             ! -- This code temporarily takes control away from the processmgr ! -- ;
  60.                 while not TRAP.TOOLBOXgetnextEvent(mousedownmask,theEvent.what) do ;
  61.                 tempW.disposeWindow;
  62.             end;
  63.         end
  64.         else
  65.         begin
  66.             ! run a desk-accesoir;
  67.             theAcc:-blanks(256);
  68.             
  69.             TRAP.toolboxGetItem(menuhandle,item,theAcc);
  70.             theAcc:-string_text(theAcc);
  71.             Desk.openDeskAcc(theAcc);
  72.         end;
  73.     end -- do menu -- ;
  74.  
  75.     ! -- initialization - build the menu -- ;    
  76.  
  77.     TRAP:-new toolboxmenu;
  78.     desk:-new macdeskmgr;
  79.         
  80.     newMenu(32000,"!20!"); !the small apple - !20!=16R14 or $14 ;
  81.     AppendMenu("About Simula...");
  82.     AppendMenu("-");
  83.     AddResmenu("DRVR"); ! add all Desk acc,  in system file resources ;
  84.     
  85. END --- Default Apple Menu --- ;